//=============================================================================
//
// Controls:
// - A, D, W, S: Move Camera
// - X, Z: Zoom in, zoom out
//
//=============================================================================

#pragma once

#include <DirectXMath.h>

#include "D3DFramework.h"
#include "Land.h"
#include "Light.h"
#include "Waves.h"

struct ID3D10BlendState;

namespace D3D10
{
	class MainApplication : public D3DFramework
	{
	public:
		MainApplication(const HINSTANCE hInstance);
		~MainApplication();
	
		void init();
		void onResize();
		void updateScene(const float deltaTime);
		void drawScene(); 
	
	private:
		void initEffect();
		void initInputLayout();
		void initBlendState();
		void initLights();

        void restoreDefaultStates();

		void updateViewMatrix(const float deltaTime);
		void updateWaves(const float deltaTime);
        void updateLights();
	
	private:	
		D3D10Utils::Land mLand;
		D3D10Utils::Waves mWaves;
                
        D3D10Utils::DirectionalLight mDirectionalLight;
        D3D10Utils::PointLight mPointLight;
        D3D10Utils::SpotLight mSpotLight;

        DirectX::XMFLOAT4X4A mLandWorld;
		DirectX::XMFLOAT4X4A mWavesWorld;

		DirectX::XMFLOAT4X4A mView;
		DirectX::XMFLOAT4X4A mProjection;
		DirectX::XMFLOAT4X4A mWVP;

		DirectX::XMFLOAT3A mEyePosition;

        DirectX::XMFLOAT2A mWaterTextureOffset;

		ID3D10ShaderResourceView *mGrassMapRV;
		ID3D10ShaderResourceView *mWaterMapRV;
		ID3D10ShaderResourceView *mSpecularMapRV;

		ID3D10BlendState *mBlendState;		
			
		float mRadius;
		float mTheta;
		float mPhi;

		float mWavesTranslationOffset;
	};
}
